package com.tron.dobest.java.trontest;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.util.Assert;

import java.util.Arrays;
import java.util.List;

/**
 * 描述：
 *
 * @author TRON
 * @since 2020-03-17
 */
public class PasswordVerify {
    public static void main(String[] args) {
        String password = "8#";
        String p1 = ".*[0-9].*";
        String p2 = ".*[a-z].*";
        List<MyPattern> strings = Arrays.asList(new MyPattern(p1,"必须包含数字"),new MyPattern(p2,"必须包含字母"));
        strings.forEach(e->{
            boolean matches = password.matches(e.getRegex());
            Assert.isTrue(matches,e.getMessage());
        });
    }

    @Data
    @AllArgsConstructor
    public static class MyPattern{
        String regex;
        String message;
    }
}
